package edu.fdzc.springboot01.utils;

import java.util.HashMap;
import java.util.Map;

public class ResultUtil {

    public static Map<String, Object> success() {
        Map<String, Object> result = new HashMap<>();
        result.put("code", 200);
        result.put("message", "操作成功");
        return result;
    }

    public static Map<String, Object> success(Object data) {
        Map<String, Object> result = success();
        result.put("data", data);
        return result;
    }

    public static Map<String, Object> fail() {
        Map<String, Object> result = new HashMap<>();
        result.put("code", 500);
        result.put("message", "操作失败");
        return result;
    }

    public static Map<String, Object> fail(String message) {
        Map<String, Object> result = new HashMap<>();
        result.put("code", 500);
        result.put("message", message);
        return result;
    }
}